package com.onehash.onebilling.entity;

/**
 * <p>Title: VRENT Video Rental System</p>
 *
 * <p>Description: A program that handles the business process of VRENT Video
 * Rental Shop</p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: NUS</p>
 *
 * @author: Feng Jianda
 * @version 1.0
 */
/* vrent imports */
/*
import vrent.application.rental.*;
import vrent.application.policy.*;
import vrent.application.member.*;
import vrent.application.report.*;
import vrent.application.reward.*;
import vrent.application.disc.*;
import vrent.storage.*;
*/
/* java imports */
import java.util.Vector;
import java.io.*;

public class MasterRecord {
    // Instance of the Singleton class
    private static MasterRecord masterRecInstance;
    ///////////////////////////////////////////////
    /* Record Classes */
    /*
    private PolicyRecord policyRecord;
    private RentalRecord rentalRecord;
    private OutstandingFeeRecord feeRecord;
    private MemberRecord memberRecord;
    private DiscInventory discInventory;
    private DiscCatalog discCatalog;
    private AccountRecord accRecord;
    private DiscType discType;
    private GiftRecord giftRecord;
    private RewardPointsRecord rewardPointsRecord;
    */
    /******************************/

    private MasterRecord() {
        /* Creating Record Classes */
    	/*
        policyRecord=PolicyRecord.getInstance();
        rentalRecord=RentalRecord.getInstance();
        feeRecord=OutstandingFeeRecord.getInstance();
        memberRecord=MemberRecord.getInstance();
        discInventory=DiscInventory.getInstance();
        discCatalog=DiscCatalog.getInstance();
        accRecord=AccountRecord.getInstance();
        discType=DiscType.getInstance();
        giftRecord=GiftRecord.getInstance();
        rewardPointsRecord=RewardPointsRecord.getInstance();
        */
        /******************************/
    }

    public static MasterRecord getInstance(){
        if(masterRecInstance==null){
            masterRecInstance=new MasterRecord();
        }
        return masterRecInstance;
    }

    // Getter methods
    /*
    public DiscInventory getDiscInventory(){ return this.discInventory; }
    public DiscCatalog getDiscCatalog(){ return this.discCatalog; }
    public PolicyRecord getPolicyRecord(){ return this.policyRecord; }
    public RentalRecord getRentalRecord(){ return this.rentalRecord; }
    public OutstandingFeeRecord getFeeRecord(){ return this.feeRecord; }
    public MemberRecord getMemberRecord(){ return this.memberRecord; }
    public AccountRecord getAccountRecord(){ return this.accRecord; }
    public DiscType getDiscTypes(){ return this.discType; }
    public GiftRecord getGiftRecord(){ return this.giftRecord; }
    public RewardPointsRecord getRewardPointsRecord(){ return this.rewardPointsRecord; }
*/
    
    public void serializeDiscType() throws FileNotFoundException, IOException{
       // VrentStorage storage = VrentStorage.getInstance();
        // Writing DiscType
       // storage.writeObjects(discType.getVector(), VrentStorage.DISCTYPE_FILENAME);
    }

    public void serializeAccountRec() throws FileNotFoundException, IOException{
       // VrentStorage storage = VrentStorage.getInstance();
        //Writing AccountRecord
      //  storage.writeObjects(accRecord.getVector(),
       //                          VrentStorage.ACC_OBJ_FILENAME);
    }

    public void serializeGiftRec() throws FileNotFoundException, IOException{
      //  VrentStorage storage = VrentStorage.getInstance();
        //Writing GiftRecord
      //  storage.writeObjects(giftRecord.getVector(), VrentStorage.GIFT_OBJ_FILENAME);
    }

    public void serializeMain() throws FileNotFoundException, IOException{
      //  VrentStorage storage = VrentStorage.getInstance();
        //Creating Buffer for writing
      //  Vector buffer = new Vector();
        //Add discCatalog
       // buffer.addAll(discCatalog.getVector());
        //Add discInventory
       // buffer.addAll(discInventory.getVector());
        //Add policy
      //  buffer.addAll(policyRecord.getVector());
        //Add memberRecord
       // buffer.addAll(memberRecord.getMembers());
        //Add rentalRecord
       // buffer.addAll(rentalRecord.getVector());
        //Add oustandingFeeRecord
       // buffer.addAll(feeRecord.getVector());
        //Add rewardPointsRecord
       // buffer.addAll(rewardPointsRecord.getVector());
        // Writing buffer to file
      //  storage.writeObjects(buffer, VrentStorage.MAIN_OBJ_FILENAME);
    }

    public void serializeAll() throws FileNotFoundException, IOException{
      //  VrentStorage storage = VrentStorage.getInstance();

        //Writing DiscType
        this.serializeDiscType();
        //Writing AccountRecord
        this.serializeAccountRec();
        //Writing GiftRecord
        this.serializeGiftRec();
        //Writing main records
        this.serializeMain();
    }

    public void deserializeDiscType() throws FileNotFoundException, IOException{
       // VrentStorage storage=VrentStorage.getInstance();
        //Reading DiscType
       // discType.setVector(storage.readObjects(VrentStorage.DISCTYPE_FILENAME));
    }

    public void deserializeAccountRec() throws FileNotFoundException, IOException{
      //  VrentStorage storage=VrentStorage.getInstance();
        //Reading AccountRecord
      //  accRecord.setVector(storage.readObjects(VrentStorage.ACC_OBJ_FILENAME));
    }

    public void deserializeGiftRec() throws FileNotFoundException, IOException{
      //  VrentStorage storage=VrentStorage.getInstance();
        //Reading GiftRecord
      //  giftRecord.setVector(storage.readObjects(VrentStorage.GIFT_OBJ_FILENAME));
    }

    public void deserializeMain() throws FileNotFoundException, IOException{
       // VrentStorage storage=VrentStorage.getInstance();
       // Vector buffer=storage.readObjects(VrentStorage.MAIN_OBJ_FILENAME);

    	/*
        for (int i = 0; i < buffer.size(); i++) {
            // Object class type is DiscTitle
            if(buffer.elementAt(i).getClass() == DiscTitle.class){
                discCatalog.addDiscTitle(buffer.elementAt(i));
            } //Object class type is DiscItem
            else if(buffer.elementAt(i).getClass() == DiscItem.class){
                discInventory.addDiscItem(buffer.elementAt(i));
            } //Object class type is MembershipPolicy
            else if(buffer.elementAt(i).getClass()==MembershipPolicy.class){
                policyRecord.addPolicy(buffer.elementAt(i));
            } // Object class type is Member class
            else if (buffer.elementAt(i).getClass() == Member.class) {
                memberRecord.deserialMember(buffer.elementAt(i));
            } // Object class type is RentedItem
            else if(buffer.elementAt(i).getClass() == RentedItem.class){
                rentalRecord.addRentedItem(buffer.elementAt(i));
            } //Object class type is OutstandingFee
            else if(buffer.elementAt(i).getClass()==OutstandingFee.class){
                feeRecord.addFee(buffer.elementAt(i));
            } // Object class type is rewardPointsRecord
            else if(buffer.elementAt(i).getClass()==RewardPointsAccount.class){
                rewardPointsRecord.addRewardPointsAccount(buffer.elementAt(i));
            }
        }
        */
    }

    public void deserializeAll() throws FileNotFoundException, IOException{
        //Reading Main records
        this.deserializeMain();

        //Reading DiscTypes
        this.deserializeDiscType();

        //Reading AccountRec
        this.deserializeAccountRec();

        //Reading GiftRecord
        this.deserializeGiftRec();
    }
}
